using System;
using System.Collections.Generic;
using System.Text;

namespace ZooApplication.Library
{
    public class LoginControler
    {
        private ILoginView _view;
        private ILoginModel _model;
	
 
        public LoginControler(ILoginView view, ILoginModel model)
        {
            this._view = view;
            this._model = model;          
        }

        public void Initialize()
        {
            this._view.ErrorMessage = "";
            this._view.BtnLogin.Click += new EventHandler(BtnLogin_Click);
        }

        public void BtnLogin_Click(object sender, EventArgs e)
        {
            if (this._model.Authenticate(this._view.EmailAddress, this._view.Password))
                this._view.RedirectFromLoginPage();
            else
                this._view.ErrorMessage = "Invalid emailaddress or password!";
        }
    }
}